package controllerMembros;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import model.eventosModel;
import model.membroModel;

/**
 * Servlet implementation class exibeMembroFoto
 */
@WebServlet("/exibeMembroFoto")
public class exibeMembroFoto extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public exibeMembroFoto() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
		membroModel membroModel = new membroModel();
		   
	      
	       
	       int id = Integer.parseInt( request.getParameter("id"));
	       
	       
		   HttpSession ses = request.getSession();  
	  
	       
	       
	        String contentType = "";  
	        String nomArquivo = "";  
	          
	        try {  
	    
	          
	     
	   // byte[] arquivo = mapBlob.getBytes(1,(new Long(mapBlob.length())).intValue());  
	  
	    response.setHeader("Cache-Control", "no-store");  
	    response.setHeader("Pragma", "no-cache");  
	    response.setDateHeader("Expires", 0);  
	    response.setContentType("image/png"); 
	     	    
	    ServletOutputStream out = response.getOutputStream();  
	    out.write(membroModel.getMembroListaFoto(id));  
	    out.flush();  
	    out.close();  
	              
	        } catch (Exception ex) {  
	            ex.printStackTrace();  
	        }  
	        finally {  
	            
	        }  
	    }
	
	
	

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
